public class Text {


    public int maxArea(int[] height) {
        int solw = 0;
        int flot = height.length - 1;
        int ret = 0;
        while(solw < flot){
            ret = Math.max(ret,Math.min(height[solw],height[flot]) * (flot - solw));
            if(height[solw] < height[flot]){
                solw++;
            }else {
                flot--;
            }
        }
        return ret;
    }


    public static int isSum(int num){
        int n = 0;
        while (num != 0){
            int tmp = num % 10;
            n += tmp * tmp;
            num /= 10;
        }
        return n;
    }


    public static boolean isHappy(int n) {
        int slow = n;
        int falt = isSum(n);
        while (slow != falt){
            slow = isSum(slow);
            falt = isSum(isSum(falt));
        }

        return slow == 1;
    }

    public static void main(String[] args) {
        System.out.println(isHappy(19));
    }
}
